namespace DotNetNuke.Data
{
    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Entities.Users;
    using DotNetNuke.Framework.Providers;
    using Microsoft.ApplicationBlocks.Data;

    
    using System;
    using System.Collections;
    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Web;
    using VB2CS;

    public class SqlDataProvider : DataProvider
    {
        private string _connectionString;
        private string _databaseFile;
        private string _databaseOwner;
        private string _objectQualifier;
        private ProviderConfiguration _providerConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
        private string _providerPath;
        private string _templateFile;
        private string _upgradeConnectionString;
        //private string DataDirectory = (Globals.ApplicationMapPath + @"\App_Data\");
        private string DataDirectory = (DotNetNuke.Common.Globals.ApplicationMapPath + @"\App_Data\");
        private const string ProviderType = "data";

        public SqlDataProvider()
        {
            Provider objProvider = (Provider) this._providerConfiguration.Providers[this._providerConfiguration.DefaultProvider];
            this._connectionString = Config.GetConnectionString(objProvider.Attributes["connectionStringName"]);
            if (this._connectionString == "")
            {
                this._connectionString = objProvider.Attributes["connectionString"];
            }
            this._providerPath = objProvider.Attributes["providerPath"];
            this._objectQualifier = objProvider.Attributes["objectQualifier"];
            if ((this._objectQualifier != "") & !this._objectQualifier.EndsWith("_"))
            {
                this._objectQualifier = this._objectQualifier + "_";
            }
            this._databaseOwner = objProvider.Attributes["databaseOwner"];
            if ((this._databaseOwner != "") & !this._databaseOwner.EndsWith("."))
            {
                this._databaseOwner = this._databaseOwner + ".";
            }
            if (Convert.ToString(objProvider.Attributes["upgradeConnectionString"]) != "")
            {
                this._upgradeConnectionString = objProvider.Attributes["upgradeConnectionString"];
            }
            else
            {
                this._upgradeConnectionString = this._connectionString;
            }
            this._templateFile = objProvider.Attributes["templateFile"];
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(this._connectionString);
            this._databaseFile = builder.AttachDBFilename.Replace("|DataDirectory|", this.DataDirectory);
        }

        public override int AddAffiliate(int VendorId, DateTime StartDate, DateTime EndDate, double CPC, double CPA)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddAffiliate", new object[] { VendorId, (this.GetNull(StartDate)), (this.GetNull(EndDate)), CPC, CPA }));
        }

        public override int AddBanner(string BannerName, int VendorId, string ImageFile, string URL, int Impressions, double CPM, DateTime StartDate, DateTime EndDate, string UserName, int BannerTypeId, string Description, string GroupName, int Criteria, int Width, int Height)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddBanner", new object[] { BannerName, VendorId, (this.GetNull(ImageFile)), (this.GetNull(URL)), Impressions, CPM, (this.GetNull(StartDate)), (this.GetNull(EndDate)), UserName, BannerTypeId, (this.GetNull(Description)), (this.GetNull(GroupName)), Criteria, Width, Height }));
        }

        public override int AddDesktopModule(string ModuleName, string FolderName, string FriendlyName, string Description, string Version, bool IsPremium, bool IsAdmin, string BusinessControllerClass, int SupportedFeatures)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddDesktopModule", new object[] { ModuleName, FolderName, FriendlyName, (this.GetNull(Description)), (this.GetNull(Version)), IsPremium, IsAdmin, BusinessControllerClass, SupportedFeatures }));
        }

        public override int AddFile(int PortalId, string FileName, string Extension, long Size, int Width, int Height, string ContentType, string Folder)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddFile", new object[] { (this.GetNull(PortalId)), FileName, Extension, Size, (this.GetNull(Width)), (this.GetNull(Height)), ContentType, Folder }));
        }

        public override int AddFolder(int PortalID, string FolderPath)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddFolder", new object[] { (this.GetNull(PortalID)), FolderPath }));
        }

        public override int AddFolderPermission(int FolderID, int PermissionID, int roleID, bool AllowAccess)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddFolderPermission", new object[] { FolderID, PermissionID, roleID, AllowAccess }));
        }

        public override void AddHostSetting(string SettingName, string SettingValue, bool SettingIsSecure)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddHostSetting", new object[] { SettingName, SettingValue, SettingIsSecure });
        }

        public override int AddListEntry(string ListName, string Value, string Text, string ParentKey, bool EnableSortOrder, int DefinitionID, string Description)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddListEntry", new object[] { ListName, Value, Text, ParentKey, EnableSortOrder, DefinitionID, Description }));
        }

        public override int AddModule(int PortalID, int ModuleDefID, string ModuleTitle, bool AllTabs, string Header, string Footer, DateTime StartDate, DateTime EndDate, bool InheritViewPermissions, bool IsDeleted)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddModule", new object[] { (this.GetNull(PortalID)), ModuleDefID, ModuleTitle, AllTabs, (this.GetNull(Header)), (this.GetNull(Footer)), (this.GetNull(StartDate)), (this.GetNull(EndDate)), InheritViewPermissions, IsDeleted }));
        }

        public override int AddModuleControl(int ModuleDefId, string ControlKey, string ControlTitle, string ControlSrc, string IconFile, int ControlType, int ViewOrder, string HelpUrl)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddModuleControl", new object[] { (this.GetNull(ModuleDefId)), (this.GetNull(ControlKey)), (this.GetNull(ControlTitle)), ControlSrc, (this.GetNull(IconFile)), ControlType, (this.GetNull(ViewOrder)), (this.GetNull(HelpUrl)) }));
        }

        public override int AddModuleDefinition(int DesktopModuleId, string FriendlyName, int DefaultCacheTime)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddModuleDefinition", new object[] { DesktopModuleId, FriendlyName, DefaultCacheTime }));
        }

        public override int AddModulePermission(int moduleID, int PermissionID, int roleID, bool AllowAccess)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddModulePermission", new object[] { moduleID, PermissionID, roleID, AllowAccess }));
        }

        public override void AddModuleSetting(int ModuleId, string SettingName, string SettingValue)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddModuleSetting", new object[] { ModuleId, SettingName, SettingValue });
        }

        public override int AddPermission(string permissionCode, int moduleDefID, string permissionKey, string permissionName)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddPermission", new object[] { moduleDefID, permissionCode, permissionKey, permissionName }));
        }

        public override int AddPortalAlias(int PortalID, string HTTPAlias)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddPortalAlias", new object[] { PortalID, HTTPAlias }));
        }

        public override int AddPortalDesktopModule(int PortalId, int DesktopModuleId)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddPortalDesktopModule", new object[] { PortalId, DesktopModuleId }));
        }

        public override int AddPortalInfo(string PortalName, string Currency, string FirstName, string LastName, string Username, string Password, string Email, DateTime ExpiryDate, double HostFee, double HostSpace, int SiteLogHistory, string HomeDirectory)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddPortalInfo", new object[] { PortalName, Currency, FirstName, LastName, Username, Password, Email, (this.GetNull(ExpiryDate)), HostFee, HostSpace, (this.GetNull(SiteLogHistory)), HomeDirectory }));
        }

        public override void AddProfile(int UserId, int PortalId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddProfile", new object[] { UserId, PortalId });
        }

        public override int AddRole(int PortalId, string RoleName, string Description, float ServiceFee, string BillingPeriod, string BillingFrequency, float TrialFee, int TrialPeriod, string TrialFrequency, bool IsPublic, bool AutoAssignment)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddRole", new object[] { PortalId, RoleName, Description, ServiceFee, BillingPeriod, (this.GetNull(BillingFrequency)), TrialFee, TrialPeriod, (this.GetNull(TrialFrequency)), IsPublic, AutoAssignment }));
        }

        public override int AddSearchItem(string Title, string Description, int Author, DateTime PubDate, int ModuleId, string Key, string Guid, int ImageFileId)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddSearchItem", new object[] { Title, Description, (this.GetNull(Author)), (this.GetNull(PubDate)), ModuleId, Key, Guid, ImageFileId }));
        }

        public override int AddSearchItemWord(int SearchItemId, int SearchWordsID, int Occurrences)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddSearchItemWord", new object[] { SearchItemId, SearchWordsID, Occurrences }));
        }

        public override void AddSearchItemWordPosition(int SearchItemWordID, string ContentPositions)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddSearchItemWordPosition", new object[] { SearchItemWordID, ContentPositions });
        }

        public override int AddSearchWord(string Word)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddSearchWord", new object[] { Word }));
        }

        public override void AddSiteLog(DateTime DateTime, int PortalId, int UserId, string Referrer, string URL, string UserAgent, string UserHostAddress, string UserHostName, int TabId, int AffiliateId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddSiteLog", new object[] { DateTime, PortalId, (this.GetNull(UserId)), (this.GetNull(Referrer)), (this.GetNull(URL)), (this.GetNull(UserAgent)), (this.GetNull(UserHostAddress)), (this.GetNull(UserHostName)), (this.GetNull(TabId)), (this.GetNull(AffiliateId)) });
        }

        public override int AddSkin(string SkinRoot, int PortalId, int SkinType, string SkinSrc)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddSkin", new object[] { SkinRoot, (this.GetNull(PortalId)), SkinType, SkinSrc }));
        }

        public override int AddTab(int PortalId, string TabName, bool IsVisible, bool DisableLink, int ParentId, string IconFile, string Title, string Description, string KeyWords, string Url, string SkinSrc, string ContainerSrc, string TabPath, DateTime StartDate, DateTime EndDate, int RefreshInterval, string PageHeadText)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddTab", new object[] { 
                (this.GetNull(PortalId)), TabName, IsVisible, DisableLink, (this.GetNull(ParentId)), IconFile, Title, Description, KeyWords, Url, (this.GetNull(SkinSrc)), (this.GetNull(ContainerSrc)), TabPath, (this.GetNull(StartDate)), (this.GetNull(EndDate)), (this.GetNull(RefreshInterval)), 
                (this.GetNull(PageHeadText))
             }));
        }

        public override void AddTabModule(int TabId, int ModuleId, int ModuleOrder, string PaneName, int CacheTime, string Alignment, string Color, string Border, string IconFile, int Visibility, string ContainerSrc, bool DisplayTitle, bool DisplayPrint, bool DisplaySyndicate)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddTabModule", new object[] { TabId, ModuleId, ModuleOrder, PaneName, CacheTime, (this.GetNull(Alignment)), (this.GetNull(Color)), (this.GetNull(Border)), (this.GetNull(IconFile)), Visibility, (this.GetNull(ContainerSrc)), DisplayTitle, DisplayPrint, DisplaySyndicate });
        }

        public override void AddTabModuleSetting(int TabModuleId, string SettingName, string SettingValue)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddTabModuleSetting", new object[] { TabModuleId, SettingName, SettingValue });
        }

        public override int AddTabPermission(int TabID, int PermissionID, int roleID, bool AllowAccess)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddTabPermission", new object[] { TabID, PermissionID, roleID, AllowAccess }));
        }

        public override void AddUrl(int PortalID, string Url)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddUrl", new object[] { PortalID, Url });
        }

        public override void AddUrlLog(int UrlTrackingID, int UserID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddUrlLog", new object[] { UrlTrackingID, (this.GetNull(UserID)) });
        }

        public override void AddUrlTracking(int PortalID, string Url, string UrlType, bool LogActivity, bool TrackClicks, int ModuleID, bool NewWindow)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddUrlTracking", new object[] { PortalID, Url, UrlType, LogActivity, TrackClicks, (this.GetNull(ModuleID)), NewWindow });
        }

        public override int AddUser(int PortalID, string Username, string FirstName, string LastName, int AffiliateId, bool IsSuperUser, string Email)
        {
            int AddUser;
            try
            {
                AddUser = Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddUser", new object[] { PortalID, Username, FirstName, LastName, (this.GetNull(AffiliateId)), IsSuperUser, Email }));
            }
            catch //(Exception exception1)
            {

                AddUser = -1;

                return AddUser;

            }
            return AddUser;
        }

        public override int AddUserRole(int PortalId, int UserId, int RoleId, DateTime ExpiryDate)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddUserRole", new object[] { PortalId, UserId, RoleId, (this.GetNull(ExpiryDate)) }));
        }

        public override int AddVendor(int PortalId, string VendorName, string Unit, string Street, string City, string Region, string Country, string PostalCode, string Telephone, string Fax, string Cell, string Email, string Website, string FirstName, string LastName, string UserName, string LogoFile, string KeyWords, string Authorized)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddVendor", new object[] { 
                (this.GetNull(PortalId)), VendorName, Unit, Street, City, Region, Country, PostalCode, Telephone, Fax, Cell, Email, Website, FirstName, LastName, UserName, 
                LogoFile, KeyWords, bool.Parse(Authorized)
             }));
        }

        public override int AddVendorClassification(int VendorId, int ClassificationId)
        {
            return Convert.ToInt32(SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "AddVendorClassification", new object[] { VendorId, ClassificationId }));
        }

        public override void DeleteAffiliate(int AffiliateId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteAffiliate", new object[] { AffiliateId });
        }

        public override void DeleteBanner(int BannerId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteBanner", new object[] { BannerId });
        }

        public override void DeleteDesktopModule(int DesktopModuleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteDesktopModule", new object[] { DesktopModuleId });
        }

        public override void DeleteFile(int PortalId, string FileName, string Folder)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteFile", new object[] { (this.GetNull(PortalId)), FileName, Folder });
        }

        public override void DeleteFiles(int PortalId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteFiles", new object[] { (this.GetNull(PortalId)) });
        }

        public override void DeleteFolder(int PortalID, string FolderPath)
        {
            SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteFolder", new object[] { (this.GetNull(PortalID)), FolderPath });
        }

        public override void DeleteFolderPermission(int FolderPermissionID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteFolderPermission", new object[] { FolderPermissionID });
        }

        public override void DeleteFolderPermissionsByFolderPath(int PortalID, string FolderPath)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteFolderPermissionsByFolderPath", new object[] { (this.GetNull(PortalID)), FolderPath });
        }

        public override void DeleteList(string ListName, string ParentKey)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteList", new object[] { ListName, ParentKey });
        }

        public override void DeleteListEntryByID(int EntryID, bool DeleteChild)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteListEntryByID", new object[] { EntryID, DeleteChild });
        }

        public override void DeleteListEntryByListName(string ListName, string Value, bool DeleteChild)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteListEntryByListName", new object[] { ListName, Value, DeleteChild });
        }

        public override void DeleteModule(int ModuleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModule", new object[] { ModuleId });
        }

        public override void DeleteModuleControl(int ModuleControlId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModuleControl", new object[] { ModuleControlId });
        }

        public override void DeleteModuleDefinition(int ModuleDefId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModuleDefinition", new object[] { ModuleDefId });
        }

        public override void DeleteModulePermission(int modulePermissionID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModulePermission", new object[] { modulePermissionID });
        }

        public override void DeleteModulePermissionsByModuleID(int ModuleID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModulePermissionsByModuleID", new object[] { ModuleID });
        }

        public override void DeleteModuleSetting(int ModuleId, string SettingName)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModuleSetting", new object[] { ModuleId, SettingName });
        }

        public override void DeleteModuleSettings(int ModuleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteModuleSettings", new object[] { ModuleId });
        }

        public override void DeletePermission(int permissionID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeletePermission", new object[] { permissionID });
        }

        public override void DeletePortalAlias(int PortalAliasID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeletePortalAlias", new object[] { PortalAliasID });
        }

        public override void DeletePortalDesktopModules(int PortalId, int DesktopModuleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeletePortalDesktopModules", new object[] { (this.GetNull(PortalId)), (this.GetNull(DesktopModuleId)) });
        }

        public override void DeletePortalInfo(int PortalId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeletePortalInfo", new object[] { PortalId });
        }

        public override void DeleteRole(int RoleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteRole", new object[] { RoleId });
        }

        public override void DeleteSearchItem(int SearchItemId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteSearchItem", new object[] { SearchItemId });
        }

        public override void DeleteSearchItems(int ModuleID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteSearchItems", new object[] { ModuleID });
        }

        public override void DeleteSearchItemWords(int SearchItemId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteSearchItemWords", new object[] { SearchItemId });
        }

        public override void DeleteSiteLog(DateTime DateTime, int PortalId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteSiteLog", new object[] { DateTime, PortalId });
        }

        public override void DeleteSkin(string SkinRoot, int PortalId, int SkinType)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteSkin", new object[] { SkinRoot, (this.GetNull(PortalId)), SkinType });
        }

        public override void DeleteTab(int TabId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteTab", new object[] { TabId });
        }

        public override void DeleteTabModule(int TabId, int ModuleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteTabModule", new object[] { TabId, ModuleId });
        }

        public override void DeleteTabModuleSetting(int TabModuleId, string SettingName)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteTabModuleSetting", new object[] { TabModuleId, SettingName });
        }

        public override void DeleteTabModuleSettings(int TabModuleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteTabModuleSettings", new object[] { TabModuleId });
        }

        public override void DeleteTabPermission(int TabPermissionID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteTabPermission", new object[] { TabPermissionID });
        }

        public override void DeleteTabPermissionsByTabID(int TabID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteTabPermissionsByTabID", new object[] { TabID });
        }

        public override void DeleteUrl(int PortalID, string Url)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteUrl", new object[] { PortalID, Url });
        }

        public override void DeleteUrlTracking(int PortalID, string Url, int ModuleID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteUrlTracking", new object[] { PortalID, Url, (this.GetNull(ModuleID)) });
        }

        public override void DeleteUser(int UserId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteUser", new object[] { UserId });
        }

        public override void DeleteUserPortal(int UserId, int PortalId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteUserPortal", new object[] { UserId, PortalId });
        }

        public override void DeleteUserRole(int UserId, int RoleId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteUserRole", new object[] { UserId, RoleId });
        }

        public override void DeleteUsersOnline(int TimeWindow)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteUsersOnline", new object[] { TimeWindow });
        }

        public override void DeleteVendor(int VendorId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteVendor", new object[] { VendorId });
        }

        public override void DeleteVendorClassifications(int VendorId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "DeleteVendorClassifications", new object[] { VendorId });
        }

        public override string ExecuteScript(string Script)
        {
            return this.ExecuteScript(Script, false);
        }

        public override string ExecuteScript(string Script, bool UseTransactions)
        {
        //    string  SQL = "";
        //    string Exceptions = "";
        //    string Delimiter = "GO\r\n";
        //    string[] arrSQL = Strings.Split(Script, Delimiter, -1, CompareMethod.Text);
        //    if (UseTransactions)
        //    {
        //        SqlConnection Conn = new SqlConnection(this.UpgradeConnectionString);
        //        Conn.Open();
        //        try
        //        {
        //            SqlTransaction Trans = Conn.BeginTransaction();
        //            foreach (string SQL in arrSQL)
        //            {
        //                if (Strings.Trim(SQL) != "")
        //                {
        //                    SQL = SQL.Replace("{databaseOwner}", this.DatabaseOwner);
        //                    SQL = SQL.Replace("{objectQualifier}", this.ObjectQualifier);
        //                    bool IgnoreErrors = false;
        //                    if (SQL.Trim().StartsWith("{IgnoreError}"))
        //                    {
        //                        IgnoreErrors = true;
        //                        SQL = SQL.Replace("{IgnoreError}", "");
        //                    }
        //                    try
        //                    {
        //                        SqlHelper.ExecuteNonQuery(Trans, CommandType.Text, SQL);
        //                    }
        //                    catch (SqlException exception1)
        //                    {
                
        //                        SqlException objException = exception1;
        //                        if (!IgnoreErrors)
        //                        {
        //                            Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";
        //                        }
                
        //                    }
        //                }
        //            }
        //            if (Exceptions.Length == 0)
        //            {
        //                Trans.Commit();
        //            }
        //            else
        //            {
        //                Trans.Rollback();
        //                Exceptions = Exceptions + "SQL Execution failed.  Database was rolled back\r\n\r\n" + SQL + "\r\n\r\n";
        //            }
        //        }
        //        finally
        //        {
        //            Conn.Close();
        //        }
        //    }
        //    else
        //    {
        //        foreach (string SQL in arrSQL)
        //        {
        //            if (Strings.Trim(SQL) != "")
        //            {
        //                SQL = SQL.Replace("{databaseOwner}", this.DatabaseOwner).Replace("{objectQualifier}", this.ObjectQualifier);
        //                try
        //                {
        //                    SqlHelper.ExecuteNonQuery(this.UpgradeConnectionString, CommandType.Text, SQL);
        //                }
        //                catch (SqlException exception2)
        //                {
        //                    
        //                    SqlException objException = exception2;
        //                    Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";
            
        //                }
        //            }
        //        }
        //    }
        //    if (this.UpgradeConnectionString != this.ConnectionString)
        //    {
        //        try
        //        {
        //            Exceptions = Exceptions + this.GrantStoredProceduresPermission("EXECUTE", "public");
        //        }
        //        catch (SqlException exception3)
        //        {
        //            
        //            SqlException objException = exception3;
        //            Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";
    
        //        }
        //    }
        //    return Exceptions;
            string SQL = "";
            string Exceptions = "";
            string Delimiter = "GO\r\n";
            string[] arrSQL = Strings.Split(Script, Delimiter, -1, CompareMethod.Text);
            if (UseTransactions)
            {
                SqlConnection Conn = new SqlConnection(this.UpgradeConnectionString);
                Conn.Open();
                try
                {
                    SqlTransaction Trans = Conn.BeginTransaction();
                    //foreach (string SQL in arrSQL)
                    //{
                    for(int i=0;i<arrSQL.Length;++i)
                    {
                        SQL = arrSQL[i];
                        if (Strings.Trim(SQL) != "")
                        {
                            SQL = SQL.Replace("{databaseOwner}", this.DatabaseOwner);
                            SQL = SQL.Replace("{objectQualifier}", this.ObjectQualifier);
                            bool IgnoreErrors = false;
                            if (SQL.Trim().StartsWith("{IgnoreError}"))
                            {
                                IgnoreErrors = true;
                                SQL = SQL.Replace("{IgnoreError}", "");
                            }
                            try
                            {
                                SqlHelper.ExecuteNonQuery(Trans, CommandType.Text, SQL);
                            }
                            catch (SqlException exception1)
                            {

                                SqlException objException = exception1;
                                if (!IgnoreErrors)
                                {
                                    Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";
                                }

                            }
                        }
                    }
                    if (Exceptions.Length == 0)
                    {
                        Trans.Commit();
                    }
                    else
                    {
                        Trans.Rollback();
                        Exceptions = Exceptions + "SQL Execution failed.  Database was rolled back\r\n\r\n" + SQL + "\r\n\r\n";
                    }
                }
                finally
                {
                    Conn.Close();
                }
            }
            else
            {
                //foreach (string SQL in arrSQL)
                //{
                for(int i=0;i<arrSQL.Length;++i)
                {
                    SQL = arrSQL[i];
                    if (Strings.Trim(SQL) != "")
                    {
                        SQL = SQL.Replace("{databaseOwner}", this.DatabaseOwner).Replace("{objectQualifier}", this.ObjectQualifier);
                        try
                        {
                            SqlHelper.ExecuteNonQuery(this.UpgradeConnectionString, CommandType.Text, SQL);
                        }
                        catch (SqlException exception2)
                        {
                            
                            SqlException objException = exception2;
                            Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";

                        }
                    }
                }
            }
            if (this.UpgradeConnectionString != this.ConnectionString)
            {
                try
                {
                    Exceptions = Exceptions + this.GrantStoredProceduresPermission("EXECUTE", "public");
                }
                catch (SqlException exception3)
                {
                    
                    SqlException objException = exception3;
                    Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";

                }
            }
            return Exceptions;
        }

        public override IDataReader ExecuteSQL(string SQL)
        {
            IDataReader ExecuteSQL;
            SQL = SQL.Replace("{databaseOwner}", this.DatabaseOwner);
            SQL = SQL.Replace("{objectQualifier}", this.ObjectQualifier);
            try
            {
                ExecuteSQL = SqlHelper.ExecuteReader(this.ConnectionString, CommandType.Text, SQL);
            }
            catch //(Exception exception1)
            {

                ExecuteSQL = null;

                return ExecuteSQL;

            }
            return ExecuteSQL;
        }

        public override IDataReader FindBanners(int PortalId, int BannerTypeId, string GroupName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "FindBanners", new object[] { (this.GetNull(PortalId)), (this.GetNull(BannerTypeId)), (this.GetNull(GroupName)) });
        }

        public override IDataReader FindDatabaseVersion(int Major, int Minor, int Build)
        {
            return SqlHelper.ExecuteReader(this.UpgradeConnectionString, this.DatabaseOwner + this.ObjectQualifier + "FindDatabaseVersion", new object[] { Major, Minor, Build });
        }

        public override IDataReader GetAffiliate(int AffiliateId, int VendorId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAffiliate", new object[] { AffiliateId, VendorId, (this.GetNull(PortalId)) });
        }

        public override IDataReader GetAffiliates(int VendorId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAffiliates", new object[] { VendorId });
        }

        public override DataTable GetAllFiles()
        {
            return SqlHelper.ExecuteDataset(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAllFiles", new object[0]).Tables[0];
        }

        public override IDataReader GetAllModules()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAllModules", new object[0]);
        }

        public override IDataReader GetAllProfiles()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAllProfiles", new object[0]);
        }

        public override IDataReader GetAllTabs()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAllTabs", new object[0]);
        }

        public override IDataReader GetAllTabsModules(int PortalId, bool AllTabs)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAllTabsModules", new object[] { PortalId, AllTabs });
        }

        public override IDataReader GetAuthRoles(int PortalId, int ModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetAuthRoles", new object[] { PortalId, ModuleId });
        }

        public override IDataReader GetBanner(int BannerId, int VendorId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetBanner", new object[] { BannerId, VendorId, (this.GetNull(PortalId)) });
        }

        public override IDataReader GetBanners(int VendorId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetBanners", new object[] { VendorId });
        }

        public override IDataReader GetDatabaseVersion()
        {
            return SqlHelper.ExecuteReader(this.UpgradeConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDatabaseVersion", new object[0]);
        }

        public override IDataReader GetDefaultLanguageByModule(string ModuleList)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDefaultLanguageByModule", new object[] { ModuleList });
        }

        public override IDataReader GetDesktopModule(int DesktopModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDesktopModule", new object[] { DesktopModuleId });
        }

        public override IDataReader GetDesktopModuleByFriendlyName(string FriendlyName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDesktopModuleByFriendlyName", new object[] { FriendlyName });
        }

        public override IDataReader GetDesktopModuleByModuleName(string ModuleName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDesktopModuleByModuleName", new object[] { ModuleName });
        }

        public override IDataReader GetDesktopModules()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDesktopModules", new object[0]);
        }

        public override IDataReader GetDesktopModulesByPortal(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetDesktopModulesByPortal", new object[] { PortalId });
        }

        public override IDataReader GetFields(string TableName)
        {
            string SQL = "SELECT * FROM {objectQualifier}" + TableName + " WHERE 1 = 0";
            return this.ExecuteSQL(SQL);
        }

        public override IDataReader GetFile(string FileName, int PortalId, string Folder)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFile", new object[] { FileName, (this.GetNull(PortalId)), Folder });
        }

        public override IDataReader GetFileById(int FileId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFileById", new object[] { FileId, (this.GetNull(PortalId)) });
        }

        public override IDataReader GetFiles(int PortalId, string Folder)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFiles", new object[] { (this.GetNull(PortalId)), Folder });
        }

        public override IDataReader GetFolder(int PortalID, int FolderID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFolders", new object[] { (this.GetNull(PortalID)), FolderID, "" });
        }

        public override IDataReader GetFolder(int PortalID, string FolderPath)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFolders", new object[] { (this.GetNull(PortalID)), -1, FolderPath });
        }

        public override IDataReader GetFolderPermission(int FolderPermissionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFolderPermission", new object[] { FolderPermissionID });
        }

        public override IDataReader GetFolderPermissionsByFolderPath(int PortalID, string FolderPath, int PermissionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFolderPermissionsByFolderPath", new object[] { (this.GetNull(PortalID)), FolderPath, PermissionID });
        }

        public override IDataReader GetFoldersByPortal(int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetFolders", new object[] { (this.GetNull(PortalID)), -1, "" });
        }

        public override IDataReader GetHostSetting(string SettingName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetHostSetting", new object[] { SettingName });
        }

        public override IDataReader GetHostSettings()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetHostSettings", new object[0]);
        }

        public override IDataReader GetList(string ListName, string ParentKey, int DefinitionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetList", new object[] { ListName, ParentKey, DefinitionID });
        }

        public override IDataReader GetListEntries(string ListName, string ParentKey, int EntryID, int DefinitionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetListEntries", new object[] { ListName, ParentKey, EntryID, DefinitionID, "" });
        }

        public override IDataReader GetListEntriesByListName(string ListName, string Value, string ParentKey)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetListEntries", new object[] { ListName, ParentKey, -1, -1, Value });
        }

        public override IDataReader GetListGroup()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetListGroup", new object[0]);
        }

        public override IDataReader GetModule(int ModuleId, int TabId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModule", new object[] { ModuleId, (this.GetNull(TabId)) });
        }

        public override IDataReader GetModuleByDefinition(int PortalId, string FriendlyName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleByDefinition", new object[] { (this.GetNull(PortalId)), FriendlyName });
        }

        public override IDataReader GetModuleControl(int ModuleControlId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleControl", new object[] { ModuleControlId });
        }

        public override IDataReader GetModuleControlByKeyAndSrc(int ModuleDefID, string ControlKey, string ControlSrc)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleControlByKeyAndSrc", new object[] { (this.GetNull(ModuleDefID)), (this.GetNull(ControlKey)), (this.GetNull(ControlSrc)) });
        }

        public override IDataReader GetModuleControls(int ModuleDefId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleControls", new object[] { (this.GetNull(ModuleDefId)) });
        }

        public override IDataReader GetModuleControlsByKey(string ControlKey, int ModuleDefId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleControlsByKey", new object[] { (this.GetNull(ControlKey)), (this.GetNull(ModuleDefId)) });
        }

        public override IDataReader GetModuleDefinition(int ModuleDefId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleDefinition", new object[] { ModuleDefId });
        }

        public override IDataReader GetModuleDefinitionByName(int DesktopModuleId, string FriendlyName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleDefinitionByName", new object[] { DesktopModuleId, FriendlyName });
        }

        public override IDataReader GetModuleDefinitions(int DesktopModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleDefinitions", new object[] { DesktopModuleId });
        }

        public override IDataReader GetModulePermission(int modulePermissionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModulePermission", new object[] { modulePermissionID });
        }

        public override IDataReader GetModulePermissionsByModuleID(int moduleID, int PermissionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModulePermissionsByModuleID", new object[] { moduleID, PermissionID });
        }

        public override IDataReader GetModulePermissionsByPortal(int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModulePermissionsByPortal", new object[] { PortalID });
        }

        public override IDataReader GetModules(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModules", new object[] { PortalId });
        }

        public override IDataReader GetModuleSetting(int ModuleId, string SettingName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleSetting", new object[] { ModuleId, SettingName });
        }

        public override IDataReader GetModuleSettings(int ModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetModuleSettings", new object[] { ModuleId });
        }

        private object GetNull(object Field)
        {
            return Null.GetNull((Field), DBNull.Value);
        }

        public override IDataReader GetPermission(int permissionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPermission", new object[] { permissionID });
        }

        public override IDataReader GetPermissionByCodeAndKey(string PermissionCode, string PermissionKey)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPermissionByCodeAndKey", new object[] { (this.GetNull(PermissionCode)), (this.GetNull(PermissionKey)) });
        }

        public override IDataReader GetPermissionsByFolderPath(int PortalID, string Folder)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPermissionsByFolderPath", new object[] { (this.GetNull(PortalID)), Folder });
        }

        public override IDataReader GetPermissionsByModuleID(int ModuleID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPermissionsByModuleID", new object[] { ModuleID });
        }

        public override IDataReader GetPermissionsByTabID(int TabID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPermissionsByTabID", new object[] { TabID });
        }

        public override IDataReader GetPortal(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortal", new object[] { PortalId });
        }

        public override IDataReader GetPortalAlias(string PortalAlias, int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalAlias", new object[] { PortalAlias, PortalID });
        }

        public override IDataReader GetPortalAliasByPortalAliasID(int PortalAliasID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalAliasByPortalAliasID", new object[] { PortalAliasID });
        }

        public override IDataReader GetPortalAliasByPortalID(int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalAliasByPortalID", new object[] { PortalID });
        }

        public override IDataReader GetPortalByAlias(string PortalAlias)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalByAlias", new object[] { PortalAlias });
        }

        public override IDataReader GetPortalByPortalAliasID(int PortalAliasId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalByPortalAliasID", new object[] { PortalAliasId });
        }

        public override IDataReader GetPortalByTab(int TabId, string PortalAlias)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalByTab", new object[] { TabId, PortalAlias });
        }

        public override IDataReader GetPortalDesktopModules(int PortalId, int DesktopModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalDesktopModules", new object[] { (this.GetNull(PortalId)), (this.GetNull(DesktopModuleId)) });
        }

        public override IDataReader GetPortalRoles(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalRoles", new object[] { PortalId });
        }

        public override IDataReader GetPortals()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortals", new object[0]);
        }

        public override IDataReader GetPortalSpaceUsed(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalSpaceUsed", new object[] { (this.GetNull(PortalId)) });
        }

        public override IDataReader GetPortalTabModules(int PortalId, int TabId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetPortalTabModules", new object[] { PortalId, TabId });
        }

        public override IDataReader GetProfile(int UserId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetProfile", new object[] { UserId, PortalId });
        }

        public override string GetProviderPath()
        {
            HttpContext objHttpContext = HttpContext.Current;
            string GetProviderPath = this.ProviderPath;
            if (GetProviderPath != "")
            {
                GetProviderPath = objHttpContext.Server.MapPath(GetProviderPath);
                if (Directory.Exists(GetProviderPath))
                {
                    try
                    {
                        this.GetDatabaseVersion().Close();
                    }
                    catch //(Exception exception1)
                    {
        
                        if (this.DatabaseFile != string.Empty)
                        {
                            if (!Directory.Exists(this.DataDirectory))
                            {
                                Directory.CreateDirectory(this.DataDirectory);
                            }
                            if (!File.Exists(this.DatabaseFile))
                            {
                                File.Copy(GetProviderPath + this.TemplateFile, this.DatabaseFile);
                                File.SetAttributes(this.DatabaseFile, FileAttributes.Normal);
                            }
                        }
                        StreamReader objStreamReader = File.OpenText(GetProviderPath + "00.00.00." + this._providerConfiguration.DefaultProvider);
                        string strScript = objStreamReader.ReadToEnd();
                        objStreamReader.Close();
                        string errorString = this.ExecuteScript(strScript);
                        if (errorString != "")
                        {
                            GetProviderPath = "ERROR: Could not connect to database specified in connectionString for SqlDataProvider" + errorString;
                        }
        
                    }
                    return GetProviderPath;
                }
                return ("ERROR: providerPath folder " + GetProviderPath + " specified for SqlDataProvider does not exist on web server");
            }
            return "ERROR: providerPath folder value not specified in web.config for SqlDataProvider";
        }

        public override IDataReader GetRole(int RoleId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetRole", new object[] { RoleId, PortalId });
        }

        public override IDataReader GetRoleByName(int PortalId, string RoleName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetRoleByName", new object[] { PortalId, RoleName });
        }

        public override IDataReader GetRoles()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetRoles", new object[0]);
        }

        public override IDataReader GetRolesByUser(int UserId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetRolesByUser", new object[] { UserId, PortalId });
        }

        public override IDataReader GetSearchCommonWordsByLocale(string Locale)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchCommonWordsByLocale", new object[] { Locale });
        }

        public override IDataReader GetSearchIndexers()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchIndexers", new object[0]);
        }

        public override IDataReader GetSearchItem(int ModuleID, string SearchKey)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchItem", new object[] { (this.GetNull(ModuleID)), SearchKey });
        }

        public override IDataReader GetSearchItems(int PortalID, int TabID, int ModuleID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchItems", new object[] { (this.GetNull(PortalID)), (this.GetNull(TabID)), (this.GetNull(ModuleID)) });
        }

        public override IDataReader GetSearchModules(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchModules", new object[] { PortalId });
        }

        public override IDataReader GetSearchResultModules(int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchResultModules", new object[] { PortalID });
        }

        public override IDataReader GetSearchResults(int PortalID, string Word)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchResults", new object[] { PortalID, Word });
        }

        public override IDataReader GetSearchSettings(int ModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchSettings", new object[] { ModuleId });
        }

        public override IDataReader GetSearchWords()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSearchWords", new object[0]);
        }

        public override IDataReader GetServices(int PortalId, int UserId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetServices", new object[] { PortalId, (this.GetNull(UserId)) });
        }

        public override IDataReader GetSiteLog(int PortalId, string PortalAlias, string ReportName, DateTime StartDate, DateTime EndDate)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + ReportName, new object[] { PortalId, PortalAlias, StartDate, EndDate });
        }

        public override IDataReader GetSiteLogReports()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSiteLogReports", new object[0]);
        }

        public override IDataReader GetSkin(string SkinRoot, int PortalId, int SkinType)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSkin", new object[] { SkinRoot, (this.GetNull(PortalId)), SkinType });
        }

        public override IDataReader GetSuperUsers()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetSuperUsers", new object[0]);
        }

        public override IDataReader GetTab(int TabId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTab", new object[] { TabId });
        }

        public override IDataReader GetTabByName(string TabName, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabByName", new object[] { TabName, (this.GetNull(PortalId)) });
        }

        public override IDataReader GetTables()
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTables", new object[0]);
        }

        public override IDataReader GetTabModuleOrder(int TabId, string PaneName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabModuleOrder", new object[] { TabId, PaneName });
        }

        public override IDataReader GetTabModuleSetting(int TabModuleId, string SettingName)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabModuleSetting", new object[] { TabModuleId, SettingName });
        }

        public override IDataReader GetTabModuleSettings(int TabModuleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabModuleSettings", new object[] { TabModuleId });
        }

        public override IDataReader GetTabPanes(int TabId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabPanes", new object[] { TabId });
        }

        public override IDataReader GetTabPermissionsByPortal(int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabPermissionsByPortal", new object[] { PortalID });
        }

        public override IDataReader GetTabPermissionsByTabID(int TabID, int PermissionID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabPermissionsByTabID", new object[] { TabID, PermissionID });
        }

        public override IDataReader GetTabs(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabs", new object[] { PortalId });
        }

        public override IDataReader GetTabsByParentId(int ParentId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetTabsByParentId", new object[] { ParentId });
        }

        public override IDataReader GetUrl(int PortalID, string Url)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUrl", new object[] { PortalID, Url });
        }

        public override IDataReader GetUrlLog(int UrlTrackingID, DateTime StartDate, DateTime EndDate)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUrlLog", new object[] { UrlTrackingID, (this.GetNull(StartDate)), (this.GetNull(EndDate)) });
        }

        public override IDataReader GetUrls(int PortalID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUrls", new object[] { PortalID });
        }

        public override IDataReader GetUrlTracking(int PortalID, string Url, int ModuleID)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUrlTracking", new object[] { PortalID, Url, (this.GetNull(ModuleID)) });
        }

        public override IDataReader GetUser(int PortalId, int UserId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUser", new object[] { PortalId, UserId });
        }

        public override IDataReader GetUserByUsername(int PortalId, string Username)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUserByUsername", new object[] { (this.GetNull(PortalId)), Username });
        }

        public override IDataReader GetUserRole(int PortalId, int UserId, int RoleId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUserRole", new object[] { PortalId, UserId, RoleId });
        }

        public override IDataReader GetUserRolesByUsername(int PortalID, string Username, string Rolename)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUserRolesByUsername", new object[] { PortalID, (this.GetNull(Username)), (this.GetNull(Rolename)) });
        }

        public override IDataReader GetUsers(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetUsers", new object[] { (this.GetNull(PortalId)) });
        }

        public override IDataReader GetVendor(int VendorId, int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetVendor", new object[] { VendorId, (this.GetNull(PortalId)) });
        }

        public override IDataReader GetVendorClassifications(int VendorId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetVendorClassifications", new object[] { (this.GetNull(VendorId)) });
        }

        public override IDataReader GetVendors(int PortalId, bool UnAuthorized, int PageIndex, int PageSize)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetVendors", new object[] { (this.GetNull(PortalId)), UnAuthorized, (this.GetNull(PageSize)), (this.GetNull(PageIndex)) });
        }

        public override IDataReader GetVendorsByEmail(string Filter, int PortalId, int PageIndex, int PageSize)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetVendorsByEmail", new object[] { Filter, (this.GetNull(PortalId)), (this.GetNull(PageSize)), (this.GetNull(PageIndex)) });
        }

        public override IDataReader GetVendorsByName(string Filter, int PortalId, int PageIndex, int PageSize)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "GetVendorsByName", new object[] { Filter, (this.GetNull(PortalId)), (this.GetNull(PageSize)), (this.GetNull(PageIndex)) });
        }

        private string GrantStoredProceduresPermission(string Permission, string LoginOrRole)
        {
            string SQL = "";
            string Exceptions = "";
            try
            {
                SQL = SQL + "declare @exec nvarchar(2000) ";
                SQL = SQL + "declare @name varchar(150) ";
                SQL = SQL + "declare sp_cursor cursor for select o.name as name ";
                SQL = SQL + "from dbo.sysobjects o ";
                SQL = SQL + "where ( OBJECTPROPERTY(o.id, N'IsProcedure') = 1 or OBJECTPROPERTY(o.id, N'IsExtendedProc') = 1 or OBJECTPROPERTY(o.id, N'IsReplProc') = 1 ) ";
                SQL = SQL + "and OBJECTPROPERTY(o.id, N'IsMSShipped') = 0 ";
                SQL = SQL + "and o.name not like N'#%%' ";
                SQL = SQL + "and (left(o.name,len('" + this.ObjectQualifier + "')) = '" + this.ObjectQualifier + "' or left(o.name,7) = 'aspnet_') ";
                SQL = SQL + "open sp_cursor ";
                SQL = SQL + "fetch sp_cursor into @name ";
                SQL = SQL + "while @@fetch_status >= 0 ";
                SQL = SQL + "begin";
                SQL = SQL + "  select @exec = 'grant " + Permission + " on ' +  @name  + ' to " + LoginOrRole + "'";
                SQL = SQL + "  execute (@exec)";
                SQL = SQL + "  fetch sp_cursor into @name ";
                SQL = SQL + "end ";
                SQL = SQL + "deallocate sp_cursor";
                SqlHelper.ExecuteNonQuery(this.UpgradeConnectionString, CommandType.Text, SQL);
            }
            catch (SqlException exception1)
            {

                SqlException objException = exception1;
                Exceptions = Exceptions + objException.ToString() + "\r\n\r\n" + SQL + "\r\n\r\n";

            }
            return Exceptions;
        }

        public override void UpdateAffiliate(int AffiliateId, DateTime StartDate, DateTime EndDate, double CPC, double CPA)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateAffiliate", new object[] { AffiliateId, (this.GetNull(StartDate)), (this.GetNull(EndDate)), CPC, CPA });
        }

        public override void UpdateAffiliateStats(int AffiliateId, int Clicks, int Acquisitions)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateAffiliateStats", new object[] { AffiliateId, Clicks, Acquisitions });
        }

        public override void UpdateBanner(int BannerId, string BannerName, string ImageFile, string URL, int Impressions, double CPM, DateTime StartDate, DateTime EndDate, string UserName, int BannerTypeId, string Description, string GroupName, int Criteria, int Width, int Height)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateBanner", new object[] { BannerId, BannerName, (this.GetNull(ImageFile)), (this.GetNull(URL)), Impressions, CPM, (this.GetNull(StartDate)), (this.GetNull(EndDate)), UserName, BannerTypeId, (this.GetNull(Description)), (this.GetNull(GroupName)), Criteria, Width, Height });
        }

        public override void UpdateBannerClickThrough(int BannerId, int VendorId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateBannerClickThrough", new object[] { BannerId, VendorId });
        }

        public override void UpdateBannerViews(int BannerId, DateTime StartDate, DateTime EndDate)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateBannerViews", new object[] { BannerId, (this.GetNull(StartDate)), (this.GetNull(EndDate)) });
        }

        public override void UpdateDatabaseVersion(int Major, int Minor, int Build)
        {
            SqlHelper.ExecuteNonQuery(this.UpgradeConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateDatabaseVersion", new object[] { Major, Minor, Build });
        }

        public override void UpdateDesktopModule(int DesktopModuleId, string ModuleName, string FolderName, string FriendlyName, string Description, string Version, bool IsPremium, bool IsAdmin, string BusinessControllerClass, int SupportedFeatures)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateDesktopModule", new object[] { DesktopModuleId, ModuleName, FolderName, FriendlyName, (this.GetNull(Description)), (this.GetNull(Version)), IsPremium, IsAdmin, BusinessControllerClass, SupportedFeatures });
        }

        public override void UpdateFile(int FileId, string FileName, string Extension, long Size, int Width, int Height, string ContentType, string Folder)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateFile", new object[] { FileId, FileName, Extension, Size, (this.GetNull(Width)), (this.GetNull(Height)), ContentType, Folder });
        }

        public override void UpdateFolder(int PortalID, int FolderID, string FolderPath)
        {
            SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateFolder", new object[] { (this.GetNull(PortalID)), FolderID, FolderPath });
        }

        public override void UpdateFolderPermission(int FolderPermissionID, int FolderID, int PermissionID, int roleID, bool AllowAccess)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateFolderPermission", new object[] { FolderPermissionID, FolderID, PermissionID, roleID, AllowAccess });
        }

        public override void UpdateHostSetting(string SettingName, string SettingValue, bool SettingIsSecure)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateHostSetting", new object[] { SettingName, SettingValue, SettingIsSecure });
        }

        public override void UpdateListEntry(int EntryID, string ListName, string Value, string Text, string Description)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateListEntry", new object[] { EntryID, ListName, Value, Text, Description });
        }

        public override void UpdateListSortOrder(int EntryID, bool MoveUp)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateListSortOrder", new object[] { EntryID, MoveUp });
        }

        public override void UpdateModule(int ModuleId, string ModuleTitle, bool AllTabs, string Header, string Footer, DateTime StartDate, DateTime EndDate, bool InheritViewPermissions, bool IsDeleted)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateModule", new object[] { ModuleId, ModuleTitle, AllTabs, (this.GetNull(Header)), (this.GetNull(Footer)), (this.GetNull(StartDate)), (this.GetNull(EndDate)), InheritViewPermissions, IsDeleted });
        }

        public override void UpdateModuleControl(int ModuleControlId, int ModuleDefId, string ControlKey, string ControlTitle, string ControlSrc, string IconFile, int ControlType, int ViewOrder, string HelpUrl)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateModuleControl", new object[] { ModuleControlId, (this.GetNull(ModuleDefId)), (this.GetNull(ControlKey)), (this.GetNull(ControlTitle)), ControlSrc, (this.GetNull(IconFile)), ControlType, (this.GetNull(ViewOrder)), (this.GetNull(HelpUrl)) });
        }

        public override void UpdateModuleDefinition(int ModuleDefId, string FriendlyName, int DefaultCacheTime)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateModuleDefinition", new object[] { ModuleDefId, FriendlyName, DefaultCacheTime });
        }

        public override void UpdateModuleOrder(int TabId, int ModuleId, int ModuleOrder, string PaneName)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateModuleOrder", new object[] { TabId, ModuleId, ModuleOrder, PaneName });
        }

        public override void UpdateModulePermission(int modulePermissionID, int moduleID, int PermissionID, int roleID, bool AllowAccess)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateModulePermission", new object[] { modulePermissionID, moduleID, PermissionID, roleID, AllowAccess });
        }

        public override void UpdateModuleSetting(int ModuleId, string SettingName, string SettingValue)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateModuleSetting", new object[] { ModuleId, SettingName, SettingValue });
        }

        public override void UpdatePermission(int permissionID, string permissionCode, int moduleDefID, string permissionKey, string permissionName)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdatePermission", new object[] { permissionID, permissionCode, moduleDefID, permissionKey, permissionName });
        }

        public override void UpdatePortalAlias(string PortalAlias)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdatePortalAliasOnInstall", new object[] { PortalAlias });
        }

        public override void UpdatePortalAliasInfo(int PortalAliasID, int PortalID, string HTTPAlias)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdatePortalAlias", new object[] { PortalAliasID, PortalID, HTTPAlias });
        }

        public override void UpdatePortalInfo(int PortalId, string PortalName, string LogoFile, string FooterText, DateTime ExpiryDate, int UserRegistration, int BannerAdvertising, string Currency, int AdministratorId, double HostFee, double HostSpace, string PaymentProcessor, string ProcessorUserId, string ProcessorPassword, string Description, string KeyWords, string BackgroundFile, int SiteLogHistory, int SplashTabId, int HomeTabId, int LoginTabId, int UserTabId, string DefaultLanguage, int TimeZoneOffset, string HomeDirectory)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdatePortalInfo", new object[] { 
                PortalId, PortalName, (this.GetNull(LogoFile)), (this.GetNull(FooterText)), (this.GetNull(ExpiryDate)), UserRegistration, BannerAdvertising, Currency, (this.GetNull(AdministratorId)), HostFee, HostSpace, (this.GetNull(PaymentProcessor)), (this.GetNull(ProcessorUserId)), (this.GetNull(ProcessorPassword)), (this.GetNull(Description)), (this.GetNull(KeyWords)), 
                (this.GetNull(BackgroundFile)), (this.GetNull(SiteLogHistory)), (this.GetNull(SplashTabId)), (this.GetNull(HomeTabId)), (this.GetNull(LoginTabId)), (this.GetNull(UserTabId)), (this.GetNull(DefaultLanguage)), (this.GetNull(TimeZoneOffset)), HomeDirectory
             });
        }

        public override void UpdatePortalSetup(int PortalId, int AdministratorId, int AdministratorRoleId, int RegisteredRoleId, int SplashTabId, int HomeTabId, int LoginTabId, int UserTabId, int AdminTabId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdatePortalSetup", new object[] { PortalId, AdministratorId, AdministratorRoleId, RegisteredRoleId, SplashTabId, HomeTabId, LoginTabId, UserTabId, AdminTabId });
        }

        public override void UpdateProfile(int UserId, int PortalId, string ProfileData)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateProfile", new object[] { UserId, PortalId, ProfileData });
        }

        public override void UpdateRole(int RoleId, string Description, float ServiceFee, string BillingPeriod, string BillingFrequency, float TrialFee, int TrialPeriod, string TrialFrequency, bool IsPublic, bool AutoAssignment)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateRole", new object[] { RoleId, Description, ServiceFee, BillingPeriod, (this.GetNull(BillingFrequency)), TrialFee, TrialPeriod, (this.GetNull(TrialFrequency)), IsPublic, AutoAssignment });
        }

        public override void UpdateSearchItem(int SearchItemId, string Title, string Description, int Author, DateTime PubDate, int ModuleId, string Key, string Guid, int HitCount, int ImageFileId)
        {
            SqlHelper.ExecuteScalar(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateSearchItem", new object[] { SearchItemId, Title, Description, (this.GetNull(Author)), (this.GetNull(PubDate)), ModuleId, Key, Guid, HitCount, ImageFileId });
        }

        [Obsolete("This method is used for legacy support during the upgrade process (pre v3.1.1). It has been replaced by one that adds the RefreshInterval and PageHeadText variables.")]
        public override void UpdateTab(int TabId, string TabName, bool IsVisible, bool DisableLink, int ParentId, string IconFile, string Title, string Description, string KeyWords, bool IsDeleted, string Url, string SkinSrc, string ContainerSrc, string TabPath, DateTime StartDate, DateTime EndDate)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateTab", new object[] { TabId, TabName, IsVisible, DisableLink, (this.GetNull(ParentId)), IconFile, Title, Description, KeyWords, IsDeleted, Url, (this.GetNull(SkinSrc)), (this.GetNull(ContainerSrc)), TabPath, (this.GetNull(StartDate)), (this.GetNull(EndDate)) });
        }

        public override void UpdateTab(int TabId, string TabName, bool IsVisible, bool DisableLink, int ParentId, string IconFile, string Title, string Description, string KeyWords, bool IsDeleted, string Url, string SkinSrc, string ContainerSrc, string TabPath, DateTime StartDate, DateTime EndDate, int RefreshInterval, string PageHeadText)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateTab", new object[] { 
                TabId, TabName, IsVisible, DisableLink, (this.GetNull(ParentId)), IconFile, Title, Description, KeyWords, IsDeleted, Url, (this.GetNull(SkinSrc)), (this.GetNull(ContainerSrc)), TabPath, (this.GetNull(StartDate)), (this.GetNull(EndDate)), 
                (this.GetNull(RefreshInterval)), (this.GetNull(PageHeadText))
             });
        }

        public override void UpdateTabModule(int TabId, int ModuleId, int ModuleOrder, string PaneName, int CacheTime, string Alignment, string Color, string Border, string IconFile, int Visibility, string ContainerSrc, bool DisplayTitle, bool DisplayPrint, bool DisplaySyndicate)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateTabModule", new object[] { TabId, ModuleId, ModuleOrder, PaneName, CacheTime, (this.GetNull(Alignment)), (this.GetNull(Color)), (this.GetNull(Border)), (this.GetNull(IconFile)), Visibility, (this.GetNull(ContainerSrc)), DisplayTitle, DisplayPrint, DisplaySyndicate });
        }

        public override void UpdateTabModuleSetting(int TabModuleId, string SettingName, string SettingValue)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateTabModuleSetting", new object[] { TabModuleId, SettingName, SettingValue });
        }

        public override void UpdateTabOrder(int TabId, int TabOrder, int Level, int ParentId)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateTabOrder", new object[] { TabId, TabOrder, Level, (this.GetNull(ParentId)) });
        }

        public override void UpdateTabPermission(int TabPermissionID, int TabID, int PermissionID, int roleID, bool AllowAccess)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateTabPermission", new object[] { TabPermissionID, TabID, PermissionID, roleID, AllowAccess });
        }

        public override void UpdateUrlTracking(int PortalID, string Url, bool LogActivity, bool TrackClicks, int ModuleID, bool NewWindow)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateUrlTracking", new object[] { PortalID, Url, LogActivity, TrackClicks, (this.GetNull(ModuleID)), NewWindow });
        }

        public override void UpdateUrlTrackingStats(int PortalID, string Url, int ModuleID)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateUrlTrackingStats", new object[] { PortalID, Url, (this.GetNull(ModuleID)) });
        }

        public override void UpdateUser(int UserId, string FirstName, string LastName, string Email)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateUser", new object[] { UserId, FirstName, LastName, Email });
        }

        public override void UpdateUserRole(int UserRoleId, DateTime ExpiryDate)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateUserRole", new object[] { UserRoleId, (this.GetNull(ExpiryDate)) });
        }

        public override void UpdateUsersOnline(Hashtable UserList)
        {
            if (UserList.Count != 0)
            {
                IEnumerator refObjectHelperL0=null;
                try
                {
                    refObjectHelperL0 = UserList.Keys.GetEnumerator();
                    while (refObjectHelperL0.MoveNext())
                    {
                        string key = Convert.ToString(refObjectHelperL0.Current);
                        if (UserList[key] is AnonymousUserInfo)
                        {
                            AnonymousUserInfo user = (AnonymousUserInfo) UserList[key];
                            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateAnonymousUser", new object[] { user.UserID, user.PortalID, user.TabID, user.LastActiveDate });
                        }
                        else if (UserList[key] is OnlineUserInfo)
                        {
                            OnlineUserInfo user = (OnlineUserInfo) UserList[key];
                            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateOnlineUser", new object[] { user.UserID, user.PortalID, user.TabID, user.LastActiveDate });
                        }
                    }
                }
                finally
                {
                    if (refObjectHelperL0 is IDisposable)
                    {
                        (refObjectHelperL0 as IDisposable).Dispose();
                    }
                }
            }
        }

        public override void UpdateVendor(int VendorId, string VendorName, string Unit, string Street, string City, string Region, string Country, string PostalCode, string Telephone, string Fax, string Cell, string Email, string Website, string FirstName, string LastName, string UserName, string LogoFile, string KeyWords, string Authorized)
        {
            SqlHelper.ExecuteNonQuery(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UpdateVendor", new object[] { 
                VendorId, VendorName, Unit, Street, City, Region, Country, PostalCode, Telephone, Fax, Cell, Email, Website, FirstName, LastName, UserName, 
                LogoFile, KeyWords, bool.Parse(Authorized)
             });
        }

        public override void UpgradeDatabaseSchema(int Major, int Minor, int Build)
        {
        }

        public override IDataReader UserLogin(string Username, string Password)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "UserLogin", new object[] { Username, Password });
        }

        public override IDataReader VerifyPortal(int PortalId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "VerifyPortal", new object[] { PortalId });
        }

        public override IDataReader VerifyPortalTab(int PortalId, int TabId)
        {
            return SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "VerifyPortalTab", new object[] { PortalId, TabId });
        }

        public string ConnectionString
        {
            get
            {
                return this._connectionString;
            }
        }

        public string DatabaseFile
        {
            get
            {
                return this._databaseFile;
            }
        }

        public string DatabaseOwner
        {
            get
            {
                return this._databaseOwner;
            }
        }

        public string ObjectQualifier
        {
            get
            {
                return this._objectQualifier;
            }
        }

        public string ProviderPath
        {
            get
            {
                return this._providerPath;
            }
        }

        public string TemplateFile
        {
            get
            {
                return this._templateFile;
            }
        }

        public string UpgradeConnectionString
        {
            get
            {
                return this._upgradeConnectionString;
            }
        }
    }
}

